﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using VipCo.Data;

public partial class Admin_Config_QLConfig : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            txtHomePage.Text = DataRepository.ConfigHomeProvider.GetByMaConfig("URLHomePage").Ten;
            txtNameHomePage.Text = DataRepository.ConfigHomeProvider.GetByMaConfig("NameHomePage").Ten;
        }
    }

    protected void cmdLuu_Click(object sender, ImageClickEventArgs e)
    {
        string query = string.Empty;
        string queryName = string.Empty;
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["netTiersConnectionString"].ConnectionString);
        conn.Open();
        query = String.Format("UPDATE ConfigHome SET Ten = '{0}' where MaConfig = 'URLHomePage'", txtHomePage.Text);
        queryName = String.Format("UPDATE ConfigHome SET Ten = N'{0}' where MaConfig = 'NameHomePage'", txtNameHomePage.Text);
       
        SqlCommand sqlCommand = new SqlCommand();
        sqlCommand.Connection = conn;
        sqlCommand.CommandText = query;
        sqlCommand.ExecuteNonQuery();
        sqlCommand.CommandText = queryName;
        sqlCommand.ExecuteNonQuery();
    }
}